﻿@model IEnumerable<Common.Views.OrdersView>
@if (Model.Count() > 0)
{           
<table>
    <tr>
        <th>Product Name</th>
        <th>Product Image</th>
        <th>Features</th>
        <th>Quantity</th>
        <th>Date Purchased</th>
        <th>Warranty Expiry Date</th>
        <th>Status of the Fault</th>
        <th>Status Description</th>
        <th>Fault Details</th>
        <th>Date of Reported Fault</th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.ProductName)
        </td>
        <td>
            <img height="150px" width="150px" src= "@Url.Content(item.ImageLink)" alt="@Html.DisplayFor(modelItem => item.ImageLink)" />
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Features)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Quantity)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.OrderDate)
        </td>
        <td>
            @if (item.WarrantyExpiryDate > DateTime.Now)
            {
                @Html.DisplayFor(modelItem => item.WarrantyExpiryDate)
            }
            else
            {
                <div style="color:Red">
                    @Html.Label("Warranty Date is expired.")
                </div>
            }
        </td>
        <td>
            @if (item.FaultStatus != null)
            {
                @Html.DisplayFor(modelItem => item.FaultStatus)
            }
            else
            {
                @Html.Label("N/A");
            }
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FaultDescription)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FaultDetails)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DateReported)
        </td>
    </tr>
}
</table>
}
else
{
    <br /> <div style="color:Red">@Html.Label("No products were found")</div>
}